//
//  PerformanceNoticeVM.swift
//  kxf
//
//  Created by Mac on 2024/3/24.
//

import Foundation
import UIKit

class PerformanceNoticeVM: UIView {
    
    let selfHeight = kFitWidth(48)
    
    var tapBlock:(()->())?

    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: SCREEN_WIDHT, height: selfHeight))
        self.backgroundColor = .white
        self.isUserInteractionEnabled = true
        
//        let tap = UITapGestureRecognizer.init(target: self, action: #selector(tapAction))
//        self.addGestureRecognizer(tap)
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    let titleVm : RegisterViewHeadTitleVM = {
        let vm = RegisterViewHeadTitleVM.init(frame: .zero)
        vm.titleLabel.text = "平台公告"
        vm.isUserInteractionEnabled = true
        return vm
    }()
    lazy var contentLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = .black
        lab.font = .systemFont(ofSize: 14, weight: .regular)
        lab.text = "查看详情"
//        lab.isUserInteractionEnabled = true
        
        return lab
    }()
    lazy var arrowImgView : UIImageView = {
        let img = UIImageView()
        img.image = UIImage.init(named: "login_arrow_img")
        img.isUserInteractionEnabled = true
        
        return img
    }()
}

extension PerformanceNoticeVM{
    @objc func tapAction() {
        if self.tapBlock != nil{
            self.tapBlock!()
        }
    }
}

extension PerformanceNoticeVM{
    func initUI() {
        addSubview(titleVm)
        addSubview(contentLabel)
        addSubview(arrowImgView)
        
//        addSubview(tapView)
        
        setConstrait()
    }
    func setConstrait() {
        contentLabel.snp.makeConstraints { make in
            make.centerY.lessThanOrEqualToSuperview()
            make.right.equalTo(kFitWidth(-40))
        }
        arrowImgView.snp.makeConstraints { make in
            make.left.equalTo(contentLabel.snp.right).offset(kFitWidth(4))
            make.centerY.lessThanOrEqualToSuperview()
            make.width.height.equalTo(kFitWidth(20))
        }
//        tapView.snp.makeConstraints { make in
//            make.left.top.width.height.equalToSuperview()
//        }
    }
}
